#include "insertproduck.h"
#include "ui_insertproduck.h"
#include "config.h"
#include "sqlcontroller.h"
#include "maincontroller.h"

insertproduck::insertproduck(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::insertproduck)
{
    ui->setupUi(this);
    this->setWindowModality(Qt::WindowModality::ApplicationModal);//设置成为模态
}

insertproduck::~insertproduck()
{
    delete ui;
}

void insertproduck::on_ok_btn_clicked()
{
    ProductInfo produ ;
    produ.name = ui->name_edit->text();
    produ.nums = ui->nums_edit->text().toInt();
    produ.price = ui->price_edit->text().toInt();
    produ.supplier = ui->supperli_edit->text();
    produ.classify = ui->classife_deit->text();
    produ.weight = ui->weight_edit->text().toInt();
    produ.user_id = SqlController::getSqlController()->getUser_id();
    //传递
    SqlController::getSqlController()->addproduct(produ);
    MainController::getMainController()->deleteinsert();
}


void insertproduck::on_quit_btn_clicked()
{
    MainController::getMainController()->deleteinsert();
}

